package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/mixin"
)

// SysUser holds the schema definition for the SysUser entity.
type SysUser struct {
	ent.Schema
}

// Mixin of the SysUser.
func (SysUser) Mixin() []ent.Mixin {
	return []ent.Mixin{mixin.Time{}}
}

// Fields of the SysUser.
func (SysUser) Fields() []ent.Field {
	return []ent.Field{
		field.String("user_name").SchemaType(map[string]string{
			dialect.MySQL: "varchar(255)", // Override MySQL.
		}).Default("").Comment("用户账号"),

		field.String("nick_name").SchemaType(map[string]string{
			dialect.MySQL: "varchar(255)", // Override MySQL.
		}).Comment("用户姓名"),

		field.String("user_password").SchemaType(map[string]string{
			dialect.MySQL: "varchar(255)", // Override MySQL.
		}).Default("").Comment("用户密码"),

		field.String("province_code").SchemaType(map[string]string{
			dialect.MySQL: "char(2)", // Override MySQL.
		}).Comment("省"),

		field.String("city_code").SchemaType(map[string]string{
			dialect.MySQL: "char(4)", // Override MySQL.
		}).Comment("市"),

		field.String("area_code").SchemaType(map[string]string{
			dialect.MySQL: "char(6)", // Override MySQL.
		}).Comment("区"),

		field.String("status").SchemaType(map[string]string{
			dialect.MySQL: "varchar(32)", // Override MySQL.
		}).Default("enable").Comment("enable:正常，disable:禁用"),

		field.String("phone").SchemaType(map[string]string{
			dialect.MySQL: "varchar(11)", // Override MySQL.
		}).Comment("手机号"),
	}
}

// Edges of the SysUser.
func (SysUser) Edges() []ent.Edge {
	return nil
}

func (SysUser) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{Table: "sys_user"},
	}
}
